<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateCosMedia extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('cos_media', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => 'cos 对象存储表']);

        //添加数据字段
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '视图ID'])
            ->addColumn('object', 'string', ['default' => '', 'limit' => 128, 'comment' => '对象服务唯一值'])
            ->addColumn('file_name', 'string', ['default' => '', 'limit' => 255, 'comment' => '文件名'])
            ->addColumn('cos_key', 'string', ['default' => '', 'limit' => 128, 'comment' => '存储key'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间']);

        //执行创建
        $table->create();
    }
}
